# -*- coding: utf-8 -*-

from flask import Flask
from werkzeug.utils import import_string

from .config import config


def create_app(config_name=None):
    app = Flask(__name__)

    if config_name is not None:
        app.config.from_object(config[config_name])

    installed_blueprints = app.config.get('INSTALLED_BLUEPRINTS', [])
    for bp in installed_blueprints:
        bp = import_string(bp)
        app.register_blueprint(bp)

    return app

